package com.linkoog.devtools.archive.action;

import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
import com.intellij.ide.projectView.impl.nodes.PsiFileNode;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.linkoog.devtools.archive.util.SelectedItemsUtil;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class ArchiveMainGroup extends DefaultActionGroup {


    @Override
    public void update(@NotNull AnActionEvent event) {
        Project project = event.getData(CommonDataKeys.PROJECT);

        Presentation presentation = event.getPresentation();
        if (project == null){
            presentation.setEnabledAndVisible(false);
            return;
        }

        List<VirtualFile> selectedFiles = SelectedItemsUtil.getSelectedItems(event);
        presentation.setEnabledAndVisible( !selectedFiles.isEmpty());
    }

    @Override
    public @NotNull ActionUpdateThread getActionUpdateThread() {
        return ActionUpdateThread.BGT;
    }
}
